{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem Set \n",
    "\n",
    "\"For the things we have to learn before we can do them, we learn by doing them.\" - Aristotle\n",
    "\n",
    "There's nothing quite like working with a new tool to really understand it, so we have put together some exercises through this book to give you a chance to put into practice what you learned in the previous lesson(s). "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Problems using NDarray [(Official Documentation)](https://mxnet.incubator.apache.org/api/python/ndarray/ndarray.html) \n",
    "\n",
    "\n",
    "Problem 1: Initialize an ndarray of dimension 1x256 on the GPU without overwriting its memory. Then, find the index corresponding to the maximum value in the array (argmax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 1 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Problems from Linear Algebra\n",
    "\n",
    "Problem 2: Create a 4x4 matrix of random values (where values are uniformly random on the iterval [0,1]. Then create an 4x4 identity matrix (an identity of size n is the n × n square matrix with ones on the main diagonal and zeros elsewhere). Multiply the two together and verify that you get the original matrix back."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 2 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Problem 3: Create a 3x3x20 tensor such that at every x,y coordinate, moving through the z coordinate lists the [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number). So, at a z position of 0, the 3x3 matrix will be all 1s. At z-position 1, the 3x3 matrix will be all 1s. At z-position 2, the 3x3 matrix will be all 2s, at z-position 3, the 3x3 matrix will be all 3s and so forth.\n",
    "\n",
    "Hint: Create the first 2 matrices by hand and then use element-wise operations in a loop to construct the rest of the tensor. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 3 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Problem 4: What is the sum of the vector you created? What is the mean?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 4 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Problem 5: Create a vector [0,1], and another vector [1,0], and use mxnet to calculate the angle between them. Remember that the dot product of two vectors is equal to the cossine of the angle between the vectors, and that the arccos function is the inverse of cosine."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 5 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Problems from Probability\n",
    "\n",
    "Problem 6: In the classic game of Risk, the attacker can roll a maximum of three dice, while the defender can roll a maximum of two dice. Simulate the attacking and defending dice using `sample_multinomial` to try to estimate the odds that an attacker will win against a defender when both are rolling the maximum number of dice."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 6 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Problems from Automatic differentiation with ``autograd`` \n",
    "\n",
    "Problem 7: The formula for a parabola is y=ax^2+bx+c. If a=5 and b = 13, what is the slope of y when x=0.  How about when x=7? "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 7 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Problem 8: Graph the parabola described in Problem 7 and inspect the slope of y when x = 0 and x = 7. Does it match up with your answer from Problem 7?\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Problem 8 Work Area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Next\n",
    "[Chapter 2: Linear regression from scratch](../chapter02_supervised-learning/linear-regression-scratch.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For whinges or inquiries, [open an issue on  GitHub.](https://github.com/zackchase/mxnet-the-straight-dope)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Solutions to the Problem Set\n",
    "\n",
    "#### Problem 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "[0.]\n",
      "<NDArray 1 @gpu(0)>\n"
     ]
    }
   ],
   "source": [
    "import mxnet as mx\n",
    "mx.random.seed(1)\n",
    "x = mx.nd.empty(shape = (1, 256), ctx = mx.gpu(0)) # not overwriting the memory and setting context to gpu\n",
    "print(mx.nd.argmax(x, axis = 1)) # using argmax function along axis 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x:  \n",
      "[[0.52383333 0.05501367 0.03996297 0.59453225]\n",
      " [0.18596531 0.6903532  0.7727907  0.98788726]\n",
      " [0.5521489  0.01780298 0.0862769  0.3745286 ]\n",
      " [0.44139475 0.4481566  0.7155492  0.38271946]]\n",
      "<NDArray 4x4 @cpu(0)>\n",
      "y:  \n",
      "[[1. 0. 0. 0.]\n",
      " [0. 1. 0. 0.]\n",
      " [0. 0. 1. 0.]\n",
      " [0. 0. 0. 1.]]\n",
      "<NDArray 4x4 @cpu(0)>\n",
      "Product:  \n",
      "[[0.52383333 0.05501367 0.03996297 0.59453225]\n",
      " [0.18596531 0.6903532  0.7727907  0.98788726]\n",
      " [0.5521489  0.01780298 0.0862769  0.3745286 ]\n",
      " [0.44139475 0.4481566  0.7155492  0.38271946]]\n",
      "<NDArray 4x4 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "x = mx.nd.random_uniform(low=0, high=1, shape=(4, 4), ctx = mx.cpu())\n",
    "y = mx.nd.eye(4, 4, ctx = mx.cpu())\n",
    "print(\"x: \", x)\n",
    "print(\"y: \", y)\n",
    "print(\"Product: \", mx.nd.dot(x, y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "[[[1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]]\n",
      "\n",
      " [[1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]]\n",
      "\n",
      " [[1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]\n",
      "  [1.000e+00 1.000e+00 2.000e+00 3.000e+00 5.000e+00 8.000e+00 1.300e+01\n",
      "   2.100e+01 3.400e+01 5.500e+01 8.900e+01 1.440e+02 2.330e+02 3.770e+02\n",
      "   6.100e+02 9.870e+02 1.597e+03 2.584e+03 4.181e+03 6.765e+03]]]\n",
      "<NDArray 3x3x20 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "x = mx.nd.empty(shape = (3, 3, 20), ctx = mx.cpu())\n",
    "x[:,:,0] = mx.nd.ones(shape = (3, 3), ctx = mx.cpu())\n",
    "x[:,:,1] = mx.nd.ones(shape = (3, 3), ctx = mx.cpu())\n",
    "for i in range(2,20):\n",
    "    x[:,:,i] = x[:,:,i-1] + x[:,:,i-2]\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sum:  \n",
      "[159390.]\n",
      "<NDArray 1 @cpu(0)>\n",
      "Mean:  \n",
      "[885.5]\n",
      "<NDArray 1 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "print(\"Sum: \", mx.nd.sum(x))\n",
    "print(\"Mean: \", mx.nd.mean(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Angle:  \n",
      "[1.5707964]\n",
      "<NDArray 1 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "x = mx.nd.array([0,1], ctx = mx.cpu())\n",
    "y = mx.nd.array([1,0], ctx = mx.cpu())\n",
    "print(\"Angle: \", mx.nd.arccos(mx.nd.dot(x, y))) # answer is pi/2, that is 90 degress"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Odds of attacker winning:  6.938\n"
     ]
    }
   ],
   "source": [
    "# Assuming a fair dice, the probability distribution of the multinomial will be as follows.\n",
    "dice = mx.nd.ones(6) / 6\n",
    "attacker_wins = 0\n",
    "# Simulate for 10000 trials\n",
    "for i in range(10000):\n",
    "    attacker = mx.nd.sum(mx.nd.sample_multinomial(data = dice, shape = 3))\n",
    "    defender = mx.nd.sum(mx.nd.sample_multinomial(data = dice, shape = 2))\n",
    "    if attacker > defender:\n",
    "        attacker_wins += 1\n",
    "print(\"Odds of attacker winning: \", attacker_wins/1000.)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "[13. 83.]\n",
      "<NDArray 2 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "x = mx.nd.array([0, 7], ctx = mx.cpu())\n",
    "x.attach_grad()\n",
    "\n",
    "with mx.autograd.record():\n",
    "    # a = 5, b = 13, c = 10(some random value, since it will disapper once we take the differential)\n",
    "    y = (5 * (x**2)) + (13 * x) + 10\n",
    "\n",
    "y.backward()\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Problem 8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl41OW99/H3NzsJECDsSwg7IopgUBS3CiIKij09bdXWp7X22NPWHu3Vc3nUnvp0sa292qetVWvLsVpPpdrW5WhBccG1Ksgqsi8hQEIgJIEEErLMzP38cQ8GeigCmclvls/ruubKzGSS+f40+XDn/t2/+2vOOUREJHVlBF2AiIjEl4JeRCTFKehFRFKcgl5EJMUp6EVEUpyCXkQkxSnoRURSnIJeRCTFKehFRFJcVtAFAPTu3duVlJQEXYaISFJZvnx5jXOuz8e9LiGCvqSkhGXLlgVdhohIUjGz7SfyOk3diIikOAW9iEhADrWG6YyNJRX0IiIBeHntbj7xszd4ae3uuL9XQszRi4iki931zXz3+bUsXLubsf27MaCwS9zf84SD3swygWVApXNutpkNA54EioDlwA3OuVYzywX+GzgbqAU+65wrj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GACKX78ZjYI+Deg1Dk3Ht/H49pYvkdKBL1z7mXnXLQ/IIvx7QtT0TnAFudcmXOuFXgSmBNwTXHnnKtyzq2I3j+A/8UfFGxV8Wdmg4FZwMNB19JZzKwQuAj4HYBzrtU5tz/YqjpFFtDFzLKAfGBXLL95SgT93/kS8GLQRcTJIGDnEY8rSIPAO5KZlQATgSXBVtIpfgncDkSCLqQTDQP2Ao9Gp6weNrOU7vPpnKsEfgbsAKqAeufcy7F8j6QJejN7NTp/9fe3OUe85tv4P/PnBVepxIuZdQWeBm5zzjUEXU88mdlsoNo5tzzoWjpZFjAJeMg5NxFoBFL6XJSZ9cT/ZT4MGAgUmNnnY/keSbMfvXNu+vE+b2ZfBGYD01zqrhmtBIYc8Xhw9LmUZ2bZ+JCf55x7Juh6OsFU4GozuxLIA7qb2ePOuZgGQAKqACqcc4f/YnuKFA96YDqwzTm3F8DMngHOB2LWHi9pRvTHY2Yz8X/iXu2cawq6njhaCowys2FmloM/YfN8wDXFnZkZfs52vXPu50HX0xmcc3c65wY750rw/59fS4OQxzm3G9hpZmOiT00D1gVYUmfYAUwxs/zoz/o0YnwCOmlG9B/jASAXeMX/d2Kxc+5fgy0p9pxzITO7BXgJf2b+Eefc2oDL6gxTgRuAD81sVfS5u6JN6CX1fAOYFx3MlAE3BlxPXDnnlpjZU8AK/NTzSmJ8hayujBURSXEpMXUjIiL/mIJeRCTFKehFRFKcgl5EJMUp6EVEUpyCXkQkxSnoRURSnIJeRCTF/X825tQIbb4XyQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "x = np.arange(-2.0, 8.0, 0.1)\n",
    "y = (5 * (x**2)) + (13 * x) + 10\n",
    "dy = (10 * x) + 13\n",
    "\n",
    "plt.figure(1)\n",
    "plt.subplot(211)\n",
    "plt.plot(x, y)\n",
    "\n",
    "plt.subplot(212)\n",
    "plt.plot(x, dy, 'r--')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
